package com.lds.offer.entity;

/**
 * @description:
 * @author: lds
 * @create: 2022-10-08 08:03
 **/
public class TreeNode {
    public int val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(int x) { val = x; }

    /**
     *    初始化树结构
     *        3
     *      /  \
     *     1   4
     *     \
     *      2
     */
    public static TreeNode init() {
        TreeNode treeNode = new TreeNode(3);
        TreeNode treeNodeLeft = new TreeNode(1);
        TreeNode treeNodeRight = new TreeNode(4);
        TreeNode treeNodeChildRight = new TreeNode(2);
        treeNodeLeft.setRight(treeNodeChildRight);
        treeNode.setLeft(treeNodeLeft);
        treeNode.setRight(treeNodeRight);
        return treeNode;
    }


    public int getVal() {
        return val;
    }

    public void setVal(int val) {
        this.val = val;
    }

    public TreeNode getLeft() {
        return left;
    }

    public void setLeft(TreeNode left) {
        this.left = left;
    }

    public TreeNode getRight() {
        return right;
    }

    public void setRight(TreeNode right) {
        this.right = right;
    }
}
